<template>
  <div class="login-panel">
    <h2 class="title">后台管理系统</h2>
    <el-tabs type="border-card" stretch>
      <el-tab-pane>
        <template #label>
          <span><i class="el-icon-user"></i> 账号登陆</span>
        </template>
        <LoginAccount ref="accountRef" />
      </el-tab-pane>
      <el-tab-pane label="消息中心">
        <template #label>
          <span><i class="el-icon-mobile-phone"></i> 手机登录</span>
        </template>
        <LoginPhone />
      </el-tab-pane>
    </el-tabs>
    <!-- 记住密码 -->
    <div class="account-rem">
      <el-checkbox v-model="isCheck">记住密码</el-checkbox>
      <el-link type="primary">忘记密码</el-link>
    </div>
    <el-button type="primary" class="login-btn" @click="handleLogin"
      >立即登录</el-button
    >
  </div>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue'
// 引入账号登录
import LoginAccount from './login-account.vue'
// 引入手机登录
import LoginPhone from './login-phone.vue'

export default defineComponent({
  components: {
    LoginAccount,
    LoginPhone
  },
  setup() {
    const isCheck = ref(true)
    // 为了拿到对应的账号登录的实例，配置对应的类型
    const accountRef = ref<InstanceType<typeof LoginAccount>>()
    const handleLogin = () => {
      console.log('ooooo', accountRef)
      accountRef.value?.loginAction()
    }
    return {
      isCheck,
      accountRef,
      handleLogin
    }
  }
})
</script>
<style lang="scss" scoped>
.login-panel {
  width: 320px;
  .title {
    text-align: center;
  }
  .account-rem {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
  }
  .login-btn {
    margin-top: 15px;
    width: 100%;
  }
}
</style>
